import pluginVue from 'eslint-plugin-vue'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'

// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup

export default defineConfigWithVueTs(
  {
    name: 'app/files-to-lint',
    files: ['**/*.{ts,mts,tsx,vue}'],
  },

  {
    name: 'app/files-to-ignore',
    ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
  },

  pluginVue.configs['flat/essential'],
  vueTsConfigs.recommended,
  {
    rules: {
      "vue/multi-word-component-names": [
        "warn",
        {
          ignores: ["index"], // 忽略单词为 `index` 的文件
        },
      ],
      "vue/no-setup-props-destructure": ["off"], // 关闭 props 解构的警告
      "no-undef": "error", // 未定义的变量报错
    },
  },

  {
    languageOptions: {
      globals: {
        ElMessage: "readonly", // ElMessage 声明为只读全局变量
        ElMessageBox: "readonly", // ElMessageBox 声明为只读全局变量
        ElLoading: "readonly", // ElLoading 声明为只读全局变量
      },
    },
  },
)
